From: Martin Schiller Date: Tue, 7 Oct 2025 05:35:51 +0000 (+0200) Subject: xl2tpd: add support to set own hostname in proto handler X-Git-Url: http://git.openwrt.org/%22https:/collectd.org/%22http:/www.crowdsec.net//%22https%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22https%22?a=commitdiff_plain;h=b9cd720d286678fc656f6d7ed99d646e8920b6fd;p=feed%2Fpackages.git xl2tpd: add support to set own hostname in proto handler This is needed if the peer only allows certain hostnames to connect. Signed-off-by: Martin Schiller --- diff --git a/net/xl2tpd/files/l2tp.sh b/net/xl2tpd/files/l2tp.sh index 294c3ddecc..08c5fe5891 100644 --- a/net/xl2tpd/files/l2tp.sh +++ b/net/xl2tpd/files/l2tp.sh @@ -17,6 +17,7 @@ proto_l2tp_init_config() { proto_config_add_int "mtu" proto_config_add_int "checkup_interval" proto_config_add_string "server" + proto_config_add_string "hostname" available=1 no_device=1 no_proto_task=1 @@ -26,9 +27,9 @@ proto_l2tp_init_config() { proto_l2tp_setup() { local interface="$1" local optfile="/tmp/l2tp/options.${interface}" - local ip serv_addr server host + local ip serv_addr server host hostname - json_get_var server server + json_get_vars server hostname host="${server%:*}" for ip in $(resolveip -t 5 "$host"); do ( proto_add_host_dependency "$interface" "$ip" ) @@ -41,6 +42,8 @@ proto_l2tp_setup() { exit 1 } + hostname="${hostname:+hostname=$hostname}" + # Start and wait for xl2tpd if [ ! -p /var/run/xl2tpd/l2tp-control -o -z "$(pidof xl2tpd)" ]; then /etc/init.d/xl2tpd restart @@ -88,7 +91,7 @@ $mtu $pppd_options EOF - xl2tpd-control add-lac l2tp-${interface} pppoptfile=${optfile} lns=${server} || { + xl2tpd-control add-lac l2tp-${interface} pppoptfile=${optfile} lns=${server} ${hostname} || { echo "xl2tpd-control: Add l2tp-$interface failed" >&2 proto_setup_failed "$interface" exit 1